:Remote Install
set REMOTE_ADDR=%1
set UID=%2
set PWD=%3
set route=%4


cd %windir%
%windir%\netcare\netcare_install\machin_check.exe 
set machin=%errorlevel%

%windir%\netcare\netcare_install\version_check.exe 
set todo=%errorlevel%

if %todo% == 0 goto :WRONG
if %todo% == 1 goto :INSTALL
if %todo% == 2 goto :UPDATE
if %todo% == 3 goto :UPTODATE


:INSTALL
net use \\%REMOTE_ADDR%\IPC$ /u:%UID% "%PWD%"
copy \\%REMOTE_ADDR%\c$%route%\netcare\win_%machin%\netcare-agent.exe %windir%\netcare /y
sc create netcare DisplayName= "Netcare Secure Client-Side Agent" binPath= "%windir%\netcare\netcare-agent.exe" start= auto
sc description netcare "Provides continuous secure system or applications health and performance monitor."
sc start netcare
netsh firewall add portopening TCP 55555 "Netcare Agent TCP 55555"
md %windir%\netcare\version
copy %windir%\netcare\netcare_install\netcare_version.txt %windir%\netcare\version /y
net use \\%REMOTE_ADDR%\IPC$ /d /y
goto :END

:UPDATE
net use \\%REMOTE_ADDR%\IPC$ /u:%UID% "%PWD%"
sc stop netcare
copy \\%REMOTE_ADDR%\C$%route%netcare\win_%machin%\netcare-agent.exe %windir%\netcare /y
sc start netcare
copy %windir%\netcare\netcare_install\netcare_version.txt %windir%\netcare\version /y
net use \\%REMOTE_ADDR%\IPC$ /d /y
goto :END


:UPTODATE
goto :END

:WRONG
goto :END

:END
exit %todo%